<template>
    <div>
        <el-dialog :visible.sync="value" center width="70%" :show-close="false">
            <el-row :gutter="20">
                <el-col :span="8">
                    <el-card  :key="upper.id" v-for="(upper,index) in data.uppers" style="margin-bottom: 30px;">
                        <template slot="header">
                            第{{index + 1}}题
                            <span style="float: right;">
								<el-link :href="upper.upperUrl" target="_blank">下载</el-link>
							</span>
                        </template>
                        {{upper.upperContent}}
                    </el-card>
                </el-col>
                <el-col :span="16">
                    <el-table :data="data.list" :height="600" size="mini" :header-cell-style="{background:'#C0C4CC',color:'white',fontSize:'15px'}">
                        <el-table-column type="index" label="序号" align="center" width="80px"></el-table-column>
                        <el-table-column prop="nickName" label="姓名" align="center"></el-table-column>
                        <el-table-column prop="url" label="学生答题素材包" align="center">
                            <template slot-scope="scope">
                                <el-link :disabled="!scope.row.url" target="_blank" :href="scope.row.url">下载</el-link>
                            </template>
                        </el-table-column>
                        <el-table-column label="给定分数" align="center">
                            <template slot-scope="scope">
                                <el-input style="width: 100%;height: 100%;" v-model="scope.row.score" placeholder="请给分"></el-input>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-col>
            </el-row>
            <template slot="footer">
                <el-button @click="handleStudentUpperScore" type="info" plain icon="el-icon-plus" v-loading.fullscreen.lock="fullscreenLoading">提交评分</el-button>
            </template>

        </el-dialog>
    </div>
</template>

<script>

    import { getStudentUpperResultList,updateStudentUpperScore } from '@/api/academic/exam'

    export default {
        name:'student-exam-upper',
        data(){
            return {
                value: false,
                fullscreenLoading:false,
                parentData:{},
                data:{}
            }
        },
        watch:{
            value(data){
                if(data){
                    this.getStudentUpperResultList(this.parentData);
                }
            }
        },
        methods:{
            getStudentUpperResultList(data){
                getStudentUpperResultList(data).then(res=>{
                    if(res.data.success){
                        this.data = res.data.data;
                    }
                });
            },
            handleStudentUpperScore(){
                this.$confirm("确定要提交上机评分吗?","友情提示",{type:"warning"}).then(()=>{
                    this.fullscreenLoading = true;
                    updateStudentUpperScore(this.data.list).then(res=>{
                        this.$message({
                            type:res.data.success ? 'success':'error',
                            message:res.data.message,
                            center:true
                        });
                        this.value = false;
                        this.fullscreenLoading = false;
                        //this.getStudentUpperResultList(this.parentData);
                        this.$parent.getExamList(this.$parent.params);
                    });
                });
            }
        }
    }
</script>

<style>
</style>
